<?php

namespace plugin\ycMassage\app\api\controller;

use plugin\ycMassage\app\BaseController;
use plugin\ycMassage\utils\AMap;
use support\Request;

class MapController extends BaseController
{
    protected $noNeedLogin = ["regeo"];
    public function regeo(Request $request)
    {
        $appid=(int)$request->appid;
        if($request->saas_appid){
            $appid=(int)$request->saas_appid;
        }
        $lnglat=$request->post('lnglat');
        try {
            $map=new AMap($appid);
            $result=$map->regeo([
                'location'=>implode(',',$lnglat),
                'extensions'=>'base'
            ]);
            return $this->successRes($result);
        } catch (\Throwable $th) {
            return $this->fail($th->getMessage());
        }
    }
}